<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js" type="application/javascript"
  ></script>
</head>
<body>
<div id="app">

  父组件
  <el-tree :data="list">
    <template v-slot="{data}">
      <div>{{ data.name }} --- {{ data.manager }}</div>
    </template>
    <!-- 父组件通过v-slot接收遍历的值  -->
  </el-tree>
</div>
</body>
<script>
  Vue.component('el-tree', {
    // 子组件
    props: ['data'], // 子组件通过props接收数据
    data() {
      return {}
    },
    template: `
      <div>
      子组件 -- 子组件循环遍历数据
      <slot v-for="item in data" :data="item"></slot>
      </div>
    `
  })
  new Vue({
    data() {
      return {
        list: [
          { name: '董事会', manager: '曹丕' },
          { name: '行政部', manager: '刘备' },
          { name: '人事部', manager: '孙权' }
        ]
      }
    },
    methods: {},
    el: '#app'
  })
</script>
</html>
